#include "asm.h"
#include "regdef.h"
#include "inst_test.h"

LEAF(n41_ld_b_test)
    
    addi.w s0, s0 ,1
    li  s2, 0x0
###test inst
    TEST_LD_B(0xc83b0be0, 0x800d6760, 0x00007a1, 0x00007a0, 0x0000000b)
    TEST_LD_B(0x1eec280c, 0x800d4598, 0x000080c, 0x000080c, 0x0000000c)
    TEST_LD_B(0xa0afed52, 0x800d4590, 0x0000a82, 0x0000a80, 0xffffffaf)
    TEST_LD_B(0x1eb637c7, 0x800d165c, 0x0000a9a, 0x0000a98, 0xffffffb6)
    TEST_LD_B(0x85415fbc, 0x800d1430, 0x0000e48, 0x0000e48, 0xffffffbc)
    TEST_LD_B(0x499d7dd4, 0x800d4974, 0x0000edc, 0x0000edc, 0xffffffd4)
    TEST_LD_B(0xc6e31856, 0x800dd704, 0x0000e9c, 0x0000e9c, 0x00000056)
    TEST_LD_B(0x5ad99018, 0x800d68f0, 0x0000ba4, 0x0000ba4, 0x00000018)
    TEST_LD_B(0x440411ac, 0x800d74e8, 0x0000240, 0x0000240, 0xffffffac)
    TEST_LD_B(0xe5567fd6, 0x800d5f60, 0x0000418, 0x0000418, 0xffffffd6)
    TEST_LD_B(0x2ede8ae6, 0x800d3bdc, 0x0000c2d, 0x0000c2c, 0xffffff8a)
    TEST_LD_B(0x64881a10, 0x800dcd7c, 0x0000486, 0x0000484, 0xffffff88)
    TEST_LD_B(0x48fc3566, 0x800d59f4, 0x0000c52, 0x0000c50, 0xfffffffc)
    TEST_LD_B(0xd9334400, 0x800d6648, 0x0000054, 0x0000054, 0x00000000)
    TEST_LD_B(0x751c6a16, 0x800d278c, 0x0000125, 0x0000124, 0x0000006a)
    TEST_LD_B(0x59ea6680, 0x800d9b48, 0x0000f42, 0x0000f40, 0xffffffea)
    TEST_LD_B(0xfb87edd4, 0x800d3f18, 0x0000f00, 0x0000f00, 0xffffffd4)
    TEST_LD_B(0xdca52840, 0x800d3960, 0x0000efc, 0x0000efc, 0x00000040)
    TEST_LD_B(0x4cdd43c8, 0x800da6e0, 0x000013c, 0x000013c, 0xffffffc8)
    TEST_LD_B(0x6d3dceb8, 0x800d0c90, 0x0000338, 0x0000338, 0xffffffb8)
    TEST_LD_B(0xe83814f0, 0x800d44e8, 0x0000174, 0x0000174, 0xfffffff0)
    TEST_LD_B(0xbb62f9ba, 0x800d1408, 0x0000c40, 0x0000c40, 0xffffffba)
    TEST_LD_B(0x9eb52b80, 0x800dd46c, 0x00002ae, 0x00002ac, 0xffffffb5)
    TEST_LD_B(0x3fe86b54, 0x800d2424, 0x00006f7, 0x00006f4, 0x0000003f)
    TEST_LD_B(0xbbd2dc3c, 0x800d4040, 0x0000528, 0x0000528, 0x0000003c)
    TEST_LD_B(0xdc0d9270, 0x800d4e40, 0x0000c98, 0x0000c98, 0x00000070)
    TEST_LD_B(0x946b9d00, 0x800d2ba8, 0x0000d40, 0x0000d40, 0x00000000)
    TEST_LD_B(0xbe6d9734, 0x800da6d4, 0x00008f0, 0x00008f0, 0x00000034)
    TEST_LD_B(0x16e0b3c0, 0x800d80ac, 0x0000feb, 0x0000fe8, 0x00000016)
    TEST_LD_B(0x6bc49d90, 0x800db9dc, 0x00005ba, 0x00005b8, 0xffffffc4)
    TEST_LD_B(0x6346f980, 0x800d7f2c, 0x0000c38, 0x0000c38, 0xffffff80)
    TEST_LD_B(0xc1a46720, 0x800d58f4, 0x00007a6, 0x00007a4, 0xffffffa4)
    TEST_LD_B(0x64cef3ac, 0x800d1498, 0x000029c, 0x000029c, 0xffffffac)
    TEST_LD_B(0xa730cfc0, 0x800d1b80, 0x000054f, 0x000054c, 0xffffffa7)
    TEST_LD_B(0x38240a20, 0x800d3280, 0x00009d3, 0x00009d0, 0x00000038)
    TEST_LD_B(0xa6f3c710, 0x800d0344, 0x00003b0, 0x00003b0, 0x00000010)
    TEST_LD_B(0x69cd6980, 0x800d73a8, 0x000059e, 0x000059c, 0xffffffcd)
    TEST_LD_B(0x7aecb546, 0x800d8730, 0x0000b60, 0x0000b60, 0x00000046)
    TEST_LD_B(0x9c244870, 0x800d2bd0, 0x0000344, 0x0000344, 0x00000070)
    TEST_LD_B(0x1dd2d522, 0x800d06d8, 0x0000376, 0x0000374, 0xffffffd2)
    TEST_LD_B(0xfca71dcc, 0x800d23a8, 0x00004dd, 0x00004dc, 0x0000001d)
    TEST_LD_B(0x8b317ee0, 0x800d0ca4, 0x000047c, 0x000047c, 0xffffffe0)
    TEST_LD_B(0x30b73214, 0x800d076c, 0x0000b4a, 0x0000b48, 0xffffffb7)
    TEST_LD_B(0xef778c1c, 0x800da97c, 0x0000df8, 0x0000df8, 0x0000001c)
    TEST_LD_B(0xc4aa18c0, 0x800d3af8, 0x00002ac, 0x00002ac, 0xffffffc0)
    TEST_LD_B(0xfe4b7514, 0x800de080, 0x00007c8, 0x00007c8, 0x00000014)
    TEST_LD_B(0x43fc33e8, 0x800d6478, 0x000027e, 0x000027c, 0xfffffffc)
    TEST_LD_B(0xa1e30564, 0x800d5e8c, 0x0000f45, 0x0000f44, 0x00000005)
    TEST_LD_B(0x9abb3880, 0x800d1de0, 0x0000e6a, 0x0000e68, 0xffffffbb)
    TEST_LD_B(0x4653e630, 0x800d244c, 0x0000878, 0x0000878, 0x00000030)
    TEST_LD_B(0xdfd32410, 0x800d833c, 0x000003c, 0x000003c, 0x00000010)
    TEST_LD_B(0xeb7c5500, 0x800d5aac, 0x0000df0, 0x0000df0, 0x00000000)
    TEST_LD_B(0xe4106bd0, 0x800d3dc4, 0x000012c, 0x000012c, 0xffffffd0)
    TEST_LD_B(0xead286f4, 0x800d50c4, 0x0000222, 0x0000220, 0xffffffd2)
    TEST_LD_B(0xe9f49570, 0x800d1d40, 0x0000724, 0x0000724, 0x00000070)
    TEST_LD_B(0xe395f2c0, 0x800dbbb8, 0x0000962, 0x0000960, 0xffffff95)
    TEST_LD_B(0x6c9caac0, 0x800d4dc4, 0x0000649, 0x0000648, 0xffffffaa)
    TEST_LD_B(0x11e6af20, 0x800d0000, 0x0000b0c, 0x0000b0c, 0x00000020)
    TEST_LD_B(0x87997498, 0x800d0000, 0x0000b00, 0x0000b00, 0xffffff98)
    TEST_LD_B(0x15abb120, 0x800d0000, 0x0000278, 0x0000278, 0x00000020)
    TEST_LD_B(0x833dd7d0, 0x800d0000, 0x0000380, 0x0000380, 0xffffffd0)
    TEST_LD_B(0x7f44e290, 0x800d0000, 0x00001d0, 0x00001d0, 0xffffff90)
    TEST_LD_B(0x992d268f, 0x800d0000, 0x0000b2f, 0x0000b2c, 0xffffff99)
    TEST_LD_B(0x15996bf7, 0x800d0000, 0x000048a, 0x0000488, 0xffffff99)
    TEST_LD_B(0x2da02d90, 0x800d0000, 0x0000c10, 0x0000c10, 0xffffff90)
    TEST_LD_B(0x24dac600, 0x800d0000, 0x00000da, 0x00000d8, 0xffffffda)
    TEST_LD_B(0xc59cd73c, 0x800d0000, 0x0000fd8, 0x0000fd8, 0x0000003c)
    TEST_LD_B(0x994a7300, 0x800d0000, 0x00002ca, 0x00002c8, 0x0000004a)
    TEST_LD_B(0x7e4051cd, 0x800d0000, 0x0000cda, 0x0000cd8, 0x00000040)
    TEST_LD_B(0xba9fb840, 0x800d0000, 0x0000b8c, 0x0000b8c, 0x00000040)
    TEST_LD_B(0x7d109500, 0x800d0000, 0x00008f7, 0x00008f4, 0x0000007d)
    TEST_LD_B(0xda709060, 0x800d0000, 0x0000780, 0x0000780, 0x00000060)
    TEST_LD_B(0xa59f9eb8, 0x800d0000, 0x0000590, 0x0000590, 0xffffffb8)
    TEST_LD_B(0x1b9b9d20, 0x800d0000, 0x0000958, 0x0000958, 0x00000020)
    TEST_LD_B(0xe945cba3, 0x800d0000, 0x0000bbc, 0x0000bbc, 0xffffffa3)
    TEST_LD_B(0x6122f40e, 0x800d0000, 0x000037a, 0x0000378, 0x00000022)
    TEST_LD_B(0x066cdae8, 0x800d0000, 0x0000d16, 0x0000d14, 0x0000006c)
    TEST_LD_B(0x31ce4d3c, 0x800d0000, 0x0000f28, 0x0000f28, 0x0000003c)
    TEST_LD_B(0xe95b473a, 0x800d0000, 0x0000c80, 0x0000c80, 0x0000003a)
    TEST_LD_B(0x27a2d01c, 0x800d0000, 0x0000d27, 0x0000d24, 0x00000027)
    TEST_LD_B(0xd3dbcfc8, 0x800d0000, 0x000020e, 0x000020c, 0xffffffdb)
    TEST_LD_B(0x604fbdca, 0x800d0000, 0x0000604, 0x0000604, 0xffffffca)
    TEST_LD_B(0xd319d84e, 0x800d0000, 0x0000a74, 0x0000a74, 0x0000004e)
    TEST_LD_B(0x65062d8d, 0x800d0000, 0x00000bc, 0x00000bc, 0xffffff8d)
    TEST_LD_B(0x6b30c710, 0x800d0000, 0x0000ee2, 0x0000ee0, 0x00000030)
    TEST_LD_B(0x0fa45c2f, 0x800d0000, 0x0000d26, 0x0000d24, 0xffffffa4)
    TEST_LD_B(0x7904ca38, 0x800d0000, 0x0000fdb, 0x0000fd8, 0x00000079)
    TEST_LD_B(0x48111e40, 0x800d0000, 0x0000d34, 0x0000d34, 0x00000040)
    TEST_LD_B(0x8b110828, 0x800d0000, 0x00004be, 0x00004bc, 0x00000011)
    TEST_LD_B(0x366c3980, 0x800d0000, 0x0000eb8, 0x0000eb8, 0xffffff80)
    TEST_LD_B(0xafa63c10, 0x800d0000, 0x00003e8, 0x00003e8, 0x00000010)
    TEST_LD_B(0x305d45e5, 0x800d0000, 0x0000c3e, 0x0000c3c, 0x0000005d)
    TEST_LD_B(0xe165f7e0, 0x800d0000, 0x0000f3e, 0x0000f3c, 0x00000065)
    TEST_LD_B(0xf28295e8, 0x800d0000, 0x00005fd, 0x00005fc, 0xffffff95)
    TEST_LD_B(0x7bcc0898, 0x800d0000, 0x0000c75, 0x0000c74, 0x00000008)
    TEST_LD_B(0xeaa165b4, 0x800d0000, 0x000037b, 0x0000378, 0xffffffea)
    TEST_LD_B(0x3ff57a80, 0x800d0000, 0x0000f03, 0x0000f00, 0x0000003f)
    TEST_LD_B(0x300e8840, 0x800d0000, 0x0000b04, 0x0000b04, 0x00000040)
    TEST_LD_B(0xfb63b448, 0x800d0000, 0x0000000, 0x0000000, 0x00000048)
    TEST_LD_B(0x358c8a40, 0x800d0000, 0x0000002, 0x0000000, 0xffffff8c)
    TEST_LD_B(0x5e903520, 0x800d0000, 0x0000000, 0x0000000, 0x00000020)
    TEST_LD_B(0x83832cc2, 0x800d0000, 0x0000001, 0x0000000, 0x0000002c)
    TEST_LD_B(0x4554da80, 0x800d0000, 0x0000002, 0x0000000, 0x00000054)
    TEST_LD_B(0x8e310700, 0x800d0000, 0x0000001, 0x0000000, 0x00000007)
    TEST_LD_B(0xf152d038, 0x800d0000, 0x0000001, 0x0000000, 0xffffffd0)
    TEST_LD_B(0xa100c498, 0x800d0000, 0x0000002, 0x0000000, 0x00000000)
    TEST_LD_B(0xea4a9128, 0x800d0000, 0x0000003, 0x0000000, 0xffffffea)
    TEST_LD_B(0x8941eeb0, 0x800d0000, 0x0000000, 0x0000000, 0xffffffb0)
    TEST_LD_B(0x1b289e0c, 0x800d0000, 0x0000002, 0x0000000, 0x00000028)
    TEST_LD_B(0x333c7a70, 0x800d0000, 0x0000002, 0x0000000, 0x0000003c)
    TEST_LD_B(0x865efaf0, 0x800d0000, 0x0000002, 0x0000000, 0x0000005e)
    TEST_LD_B(0xac40eea4, 0x800d0000, 0x0000002, 0x0000000, 0x00000040)
    TEST_LD_B(0x24b5e96a, 0x800d0000, 0x0000002, 0x0000000, 0xffffffb5)
    TEST_LD_B(0x31aa938c, 0x800d0000, 0x0000002, 0x0000000, 0xffffffaa)
    TEST_LD_B(0x0661cc00, 0x800d0000, 0x0000003, 0x0000000, 0x00000006)
    TEST_LD_B(0x7eb895a4, 0x800d0000, 0x0000001, 0x0000000, 0xffffff95)
    TEST_LD_B(0x00000000, 0x800d0000, 0x0000000, 0x0000000, 0x00000000)
###detect exception
    bne s2, zero, inst_error
###score ++
    addi.w s3, s3, 1
###output (s0<<24)|s3
inst_error:  
    slli.w t1, s0, 24
    NOP4
    or t0, t1, s3 
    NOP4
    st.w t0, s1, 0
    jirl zero, ra, 0
END(n41_ld_b_test)
